package com.utils;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Author 杨冰清
 * @Date 11:09
 * @Description
 */
public class RequestParseUtil {
    /**
     * 从请求体中读取前端传过来的字符串(json)
     * @param request
     * @return
     * @throws IOException
     */
    public static   String   getRequestBodyString(HttpServletRequest request) throws IOException {
        BufferedReader br  =new BufferedReader(new InputStreamReader(request.getInputStream(),"utf-8"));
        StringBuilder  sb =new StringBuilder();
        String str;
        while((str=br.readLine())!=null){
            sb.append(str);
        }
        br.close();
        return   sb.toString();
    }
}
